//
//  HDStringExtention.swift
//  HuaDaoPeifu
//
//  Created by 刘汉琳 on 16/5/26.
//  Copyright © 2016年 paiyipai. All rights reserved.
//

import UIKit

extension String{
    
    func getTextRectSize(_ text:NSString,font:UIFont,size:CGSize) -> CGRect {
        let attributes = [NSFontAttributeName: font]
        let option = NSStringDrawingOptions.usesLineFragmentOrigin
        let rect:CGRect = text.boundingRect(with: size, options: option, attributes: attributes, context: nil)
        return rect;
    }
    
    
    //计算一行文字的宽度  //返回宽度
    func getTextWidth(_ text:NSString,font:UIFont) ->CGFloat {
        let attributes = [NSFontAttributeName:font]
        let size = text.size(attributes: attributes)
        return size.width
    }
}
